﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Sinacor.Service.Infra.AuthorizationService.Service.ServiceImplementation.Translator
{
	public static class TranslateBetweenMenuItem
	{
		public static BusinessEntity.MenuItem ToBusinessEntity(DataContract.Response.MenuItemResponse from)
		{
			BusinessEntity.MenuItem to = new BusinessEntity.MenuItem();
			to.Assembly = from.Assembly;
			to.Classe = from.Classe;
			to.Id = from.Id;
			to.Name = from.Name;
            to.Role = from.Role;
			return to;
		}

		public static DataContract.Response.MenuItemResponse ToDataContract(BusinessEntity.MenuItem from)
		{
			DataContract.Response.MenuItemResponse to = new DataContract.Response.MenuItemResponse();
			to.Assembly = from.Assembly;
			to.Classe = from.Classe;
			to.Id = from.Id;
			to.Name = from.Name;
            to.Role = from.Role;
			if (from.Children != null && from.Children.Count > 0)
				to.Children = TranslateBetweenMenuItem.ToDataContractList(from.Children);
			return to;
		}

		public static List<DataContract.Response.MenuItemResponse> ToDataContractList(List<BusinessEntity.MenuItem> from)
		{
			List<DataContract.Response.MenuItemResponse> to = new List<DataContract.Response.MenuItemResponse>();
			foreach (BusinessEntity.MenuItem item in from)
			{
				to.Add(ToDataContract(item));
			}
			return to;
		}
	}
}